<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>主页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/admin/css/common.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
</head>

<body class="layui-layout-body">
<div class="layui-row">
    <div class="layui-col-md2  formbox " style="margin-top: 10px">

    </div>

    <div class="layui-fluid layui-col-md8 layui-col-sm12 ">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 15px;" class="layui-row">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">主板序列号:</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="mainBoard" id="mainBoard" required lay-verify="mainBoard"
                                   placeholder=""
                                   autocomplete="off" class="layui-input" style="width: 300px">
                        </div>


                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">到期时间:</label>
                        <div class="layui-input-block">
                            <input readonly name="time" id="time"
                                   class="layui-input" style="width: 300px">

                            </input>

                            <span id="daoqi" style="color: red;margin-left: 10px"></span>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">授权终端数:</label>
                        <div class="layui-input-block">
                            <input readonly name="time" id="num"
                                   class="layui-input" style="width: 300px">

                            </input>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">序列号:</label>
                        <div class="layui-input-block">
                            <input name="seri" id="seri"
                                   class="layui-input" style="width: 300px">

                            </input>

                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <div class="layui-footer" style="left: 0;">
                                <button type="button" class="layui-btn" id="btnAdd"
                                        style="margin-left:10%;width: 100px">
                                    保存
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="layui-col-md2 formbox">

    </div>
</div>
</body>
</html>

<script>
    var $ = layui.$;
    var form = layui.form;

    $(function () {
        $.ajax({
            url: '/system/getSeri',
            success: function (data) {
                if (data.code == 200) {
                    $("#mainBoard").val(data.data.mainBoradId);
                    if (data.data.system) {
                        if (data.data.system.dy_regist_code) {
                            $("#seri").val(data.data.system.dy_regist_code);
                        }
                    }

                    if (data.data.system) {
                        if (data.data.system.dy_shouquan_daoqi) {
                            var date = layui.util.toDateString(data.data.system.dy_shouquan_daoqi, 'yyyy年MM月dd日 HH:mm:ss');
                            $("#time").val(date);

                            if ($.trim(data.data.daoqi)=="true")
                            {
                                $("#daoqi").html("已到期");
                            }
                        } else {
                            $("#time").val("还没有授权");
                        }

                        if (data.data.system.dy_max_shouquan) {
                            $("#num").val(data.data.system.dy_max_shouquan);
                        } else {
                            $("#num").val("0");
                        }



                    } else {
                        $("#time").val("还没有授权");
                    }

                    $("#btnAdd")[0].disabled = false;
                    $("#btnAdd")[0].className = "layui-btn";
                } else {
                    $("#mainBoard").val("非法访问");
                    $("#btnAdd")[0].disabled = true;
                    $("#btnAdd")[0].className = "layui-btn-disabled";
                }
            }
        });
    });

    $("#btnAdd").click(function () {

        var mainBoard = $("#mainBoard").val();
        var seri = $("#seri").val();


        $.ajax({
            url: '/system/saveSeri',
            data: {mainBoard: mainBoard, seri: seri},
            async: true,
            success: function (data) {

                if (data.code == 200) {
                    layer.msg("修改成功", {icon: 1, time: 1000});
                    return false;
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                    return false;
                }

            }
        });


    });
</script>

